/**
 * @description 上传文件配置
 * @author 穆宏宇
 * @date 2020-10-19 13:46:15
 * */

import tools from "@/tools";
import { createUuid } from "@/util/common";
import md5 from 'js-md5'

// eslint-disable-next-line
const baseUrl = process.env.VUE_APP_BASE_API
const env = process.env.ENV

class FileConfig {

	constructor() {
		// 上传文件地址
		// this.url = `${baseUrl}/api/file/upload`,
		if (env == 'development') {
			this.url = `${baseUrl}/special/dictionary/files/upload/`
		} else {
			this.url = `${baseUrl}/special/dictionary/files/upload/`
		}
		var timestamp = Date.parse(new Date()) / 1000;
		var uuid = createUuid();
		var qiantai = localStorage.getItem("qiantai")?localStorage.getItem("qiantai"):'';
		var newStr = uuid + timestamp + qiantai;
		const sign = md5(newStr);
		
		// 上传文件请求头
		this.headers = () => {
			return {
				'Authorization': tools.localRead('qiantai'),
				'Metis-InternalModule': 'aaaa',
				'Metis-ReqId': createUuid(),
				'Metis-Tenant': '8dd10f97bc684b4fbc845c0b344883aa',
				'Metis-UserId': tools.localRead('userId'),
				'sign': sign,
				'uuid': uuid,
				'timestamp': timestamp,
			}
		}
	}
}

export default new FileConfig()
